package com.hl.card.modular.pack.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hl.card.common.persistence.dao.CollectAddressMapper;
import com.hl.card.common.persistence.model.CollectAddress;
import com.hl.card.modular.pack.service.CollectAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectAddressServiceImp extends ServiceImpl<CollectAddressMapper, CollectAddress>  implements CollectAddressService {
	@Autowired
	private CollectAddressMapper collectAddressMapper;
	
	/**
	 * 添加收货人信息
	 * @return 
	 */
	@Override
	public  int insertCollectAddress(CollectAddress id) {
		/*id.setCollectName("黑");
		id.setCollectPhone("1352245");
		id.setAddress("广东省深圳");
		id.setUserId("AE86藤");*/
		return collectAddressMapper.insertCollectAddress(id);
	}

	/**
	 * 修改收货人信息
	 * @return 
	 */
	@Override
	public int updateCollectAddress(CollectAddress collectAddress) {
		/*userId.setCollectName("大白");
		userId.setCollectPhone("12345678900");
		userId.setAddress("庄市黄浦区");*/
		return collectAddressMapper.updateCollectAddress(collectAddress);
	}

	@Override
	public int deleteCollectAddress(CollectAddress userId) {
		
		return collectAddressMapper.deleteCollectAddress(userId);
	}

	@Override
	public void selectCollectAddress(String userId) {
		// TODO Auto-generated method stub
		collectAddressMapper.selectCollectAddress(userId);
		
	}

	@Override
	public List<CollectAddress> list(String userId) {
		// TODO Auto-generated method stub
		return collectAddressMapper.selectCollectAddress(userId);
	}

	@Override
	public int modifyWhetherAddress(CollectAddress collectAddress) {
		       collectAddress.setWhetherAddress(1);
	           collectAddressMapper.updateCollectAddressWhetherAddressAll(collectAddress);
	           collectAddress.setWhetherAddress(0);
		return collectAddressMapper.updateCollectAddressWhetherAddress(collectAddress);
	}

	@Override
	public int modifyWhetherAddressAll(CollectAddress collectAddress) {
 
		collectAddress.setWhetherAddress(2);

		return collectAddressMapper.updateCollectAddressWhetherAddressAll(collectAddress);
	}


}





